package com.saver.core.util;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;

/**
 * Created by HeRGoS on 03/05/2015
 */
public abstract class CommonUtil {

    public static String formatCurrency(double value) {
        NumberFormat currencyFormat = NumberFormat.getCurrencyInstance();
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        symbols.setCurrencySymbol("");
        symbols.setGroupingSeparator(',');
        symbols.setMonetaryDecimalSeparator('.');
        ((DecimalFormat) currencyFormat).setDecimalFormatSymbols(symbols);
        return "S/." + currencyFormat.format(value);
    }

    public static String trim(String source) {
        if (source == null) {
            return "";
        }
        return source.trim();
    }
}
